package com.zw.cloud.tools.controller;

import com.zw.cloud.common.annotation.SendDingTalkMsgOnException;
import com.zw.cloud.common.annotation.UseTimeCount;
import com.zw.cloud.common.utils.DingTalkUtils;
import com.zw.cloud.global.response.wrapper.entity.WebResult;
import com.zw.cloud.tools.entity.dto.SuggestDTO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/dingTalk")
public class DingTalkMsgControler {

    @GetMapping
    @SendDingTalkMsgOnException
    //@UseTimeCount
    //http://localhost:9040/dingTalk
    public void testAnnotation(){

        throw new RuntimeException("测试异常");
    }

    @PostMapping
    //http://127.0.0.1:9040/dingTalk
    public WebResult<Boolean> saveOrUpdate(@RequestBody @Validated SuggestDTO suggestDTO) {
        DingTalkUtils.sendDingTalkMsg("test",suggestDTO.getContent());
        return WebResult.success(true);
    }

}
